tehwepn = NULL
switchinprog = false

function Inaccuracy(UCMD)
if LocalPlayer().leftarm != nil and LocalPlayer().rightarm != nil then
local aimspaz =  0.005*(50 - (LocalPlayer().leftarm + LocalPlayer().rightarm))
local speedofspaz = (50 - (LocalPlayer().leftarm + LocalPlayer().rightarm))
local WORKDAMNIT = LocalPlayer():GetNWBool("spazon")
if WORKDAMNIT == true then
UCMD:SetViewAngles(UCMD:GetViewAngles() + Angle(aimspaz * math.sin(0.1*speedofspaz*CurTime()), aimspaz * math.sin(0.08*speedofspaz*CurTime()),0))
end
end
end
hook.Add("CreateMove", "Inaccuracy", Inaccuracy)

function PostProcess()
if LocalPlayer().head != nil then
	if LocalPlayer().head == 0 then
		DrawMotionBlur( 0.1, 0.79, 0.05 )
	end
end

end
hook.Add( "RenderScreenspaceEffects", "ClusterFucked", PostProcess )  -- I didn't change the unique name from the wiki becaues it gave me a chuckle


function hidehud(name)
	for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do
		if name == v then return false end
	end
end
hook.Add("HUDShouldDraw", "hidehud", hidehud)

LARM = surface.GetTextureID( "LARM" )
LLEG = surface.GetTextureID( "LLEG" )
RARM = surface.GetTextureID( "RARM" )
RLEG = surface.GetTextureID( "RLEG" )
BODY = surface.GetTextureID( "BODY" )
HEAD = surface.GetTextureID( "HEAD" )

function LimbHealthPaint() -- this is where the little man is drawn :D
local client = LocalPlayer()

// HEALTH HUD DRAW //
if client.leftarm != nil then
surface.SetTexture( LARM )
surface.SetDrawColor(GreentoRed(client.leftarm, 25))
surface.DrawTexturedRect((ScrW()/6)-42.2,ScrH()-130, 43.2, 7.5)
surface.SetTexture( LLEG )
surface.SetDrawColor(GreentoRed(client.leftleg, 25))
surface.DrawTexturedRect((ScrW()/6)-12.6,ScrH()-84.7, 25.8, 45.3)
surface.SetTexture( RARM )
surface.SetDrawColor(GreentoRed(client.rightarm, 25))
surface.DrawTexturedRect((ScrW()/6)+26.1,ScrH()-130, 43.2, 7.5)
surface.SetTexture( RLEG )
surface.SetDrawColor(GreentoRed(client.rightleg, 25))
surface.DrawTexturedRect((ScrW()/6)+13,ScrH()-84.7, 25.8, 45.3)
surface.SetTexture( BODY )
surface.SetDrawColor(GreentoRed(client.body, 60))
surface.DrawTexturedRect((ScrW()/6),ScrH()-130, 26.1, 45.3)
surface.SetTexture( HEAD )
surface.SetDrawColor(GreentoRed(client.head, 10))
surface.DrawTexturedRect((ScrW()/6)+4,ScrH()-148, 18,18)
end

// FIRST AID SPRAY DRAW //
if client.SprayAmt != nil then
for q=1, client.SprayAmt do
draw.RoundedBox(2, (ScrW()/5) + (20*q), ScrH() - 90 , 15 , 30 , Color(255, 255, 255, 150) ) -- don't forget that this is in a loop, so fix it to make it spread out
draw.RoundedBox(2, (ScrW()/5) +4.5 + (20*q), ScrH() - 96 , 6 , 6 , Color(255, 255, 255, 150) )
draw.RoundedBox(0, (ScrW()/5) +5.5 + (20*q), ScrH() - 71 , 4 , 10 , Color(255, 0, 0, 200) )
draw.RoundedBox(0, (ScrW()/5) + 2.5 + (20*q) , ScrH() - 68 , 10 , 4 , Color(255, 0, 0, 200) )
end
end

// AMMO DRAW //
if client:GetActiveWeapon() != NULL then
local ammo = GetCurClip()
local ammotype = client:GetActiveWeapon():GetPrimaryAmmoType()
local curclipsize = client.clipsize

if curclipsize == -1 and ammotype == -1 then 
	--do nothing :D, for now
elseif (ammotype != -1 and curclipsize == -1) or (curclipsize and curclipsize <= 3) then

	if ammo > 15 then
	draw.RoundedBoxEx(2, (ScrW()/5)+50, ScrH() - 130 , 4 , 15 , Color(200, 200, 0, 150), true , true  , false , false )
	draw.SimpleText(string.format("x %i",ammo), "MenuLarge", (ScrW()/5) + 65, ScrH() - 122, Color(200, 200, 0, 150), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
	else
	for q=1, ammo do
	draw.RoundedBoxEx(2, (ScrW()/5)+50 + (5*q), ScrH() - 130 , 4 , 15 , Color(200, 200, 0, 150), true , true  , false , false )
	end
	end

elseif curclipsize and curclipsize > 3 then

	local clippydraw = math.floor(ammo/curclipsize)
	if clippydraw > 8 then

	draw.SimpleText(string.format("x %i",clippydraw), "MenuLarge", (ScrW()/5) + 65, ScrH() - 122, Color(0, 50, 200, 150), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
	draw.RoundedBox(2, (ScrW()/5) + 50, ScrH() - 130 , 10 , 25 , Color(0, 50, 200, 150) )
	
	else
	
	for q=1, clippydraw do
	draw.RoundedBox(2, (ScrW()/5) + 45  + (12*q), ScrH() - 130 , 10 , 25 , Color(0, 50, 200, 150) ) --make it so that broken clips have individual bullets
	end
	
	end
end
end
end
hook.Add("HUDPaint", "LimbHealthPaint", LimbHealthPaint)


function GreentoRed(limb, max)
	local multi = 255 / (max/2)
	if limb > (max/2) then
		Colour = Color(255-multi*(limb), 255, 0, 150 )
	else
		Colour = Color(255, multi*(limb), 0, 150)
	end
	return Colour
end



local function LeftArm( um )
LocalPlayer().leftarm =  um:ReadFloat()
end
usermessage.Hook( "LeftArm", LeftArm )

local function RightArm( um )
LocalPlayer().rightarm =  um:ReadFloat()
end
usermessage.Hook( "RightArm", RightArm )

local function LeftLeg( um )
LocalPlayer().leftleg =  um:ReadFloat()
end
usermessage.Hook( "LeftLeg", LeftLeg )

local function RightLeg( um )
LocalPlayer().rightleg =  um:ReadFloat()
end
usermessage.Hook( "RightLeg", RightLeg )

local function Head( um )
LocalPlayer().head =  um:ReadFloat()
end
usermessage.Hook( "Head", Head )

local function Body( um )
LocalPlayer().body =  um:ReadFloat()
end
usermessage.Hook( "Body", Body )

local function SprayAmt( um )
LocalPlayer().SprayAmt =  um:ReadFloat() -- a white can with a red cross
end
usermessage.Hook( "SprayAmt", SprayAmt )

local function clipsize( um )
LocalPlayer().clipsize =  um:ReadFloat() -- a blue rectange. This really should be a texture.
end
usermessage.Hook( "clipsize", clipsize )

function GetCurClip()
local client = LocalPlayer()
local actwep = client:GetActiveWeapon()
if actwep == NULL then return -1 end
if ( ! actwep ) then return -1 end
 
	return client:GetAmmoCount(actwep:GetPrimaryAmmoType())

	
	end
	
	
	